/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package de.stalinski.util;

import java.security.MessageDigest;

public class Crypter {

    public static String crypt(String args) throws Exception {
        /* Berechnung */
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        md5.reset();
        md5.update(args.getBytes());
        byte[] result = md5.digest();

        /* Ausgabe */
        StringBuffer hexString = new StringBuffer();
        for (int i=0; i<result.length; i++) {
            hexString.append(Integer.toHexString(0xFF & result[i]));
        }
        System.out.println("MD5: " + hexString.toString());
        return hexString.toString();
        
    }

}
